import 'package:flutter/material.dart';
import '../service/api_method.dart';
import '../model/goods_detail.dart';
import 'dart:convert';

class GoodsDetailProvide with ChangeNotifier {
  GoodsData goodsData = null;
  int _currentIndex = 0;

  // 从服务器端获取数据
  getGoodsDetailDataById(String id) {
    print(id);
    request('getGoodDetailById', params: {'goodId': id}).then((val) {
      var responseData = json.decode(val);
      // print(responseData);

      goodsData = GoodsDetail.fromJson(responseData).data;

      notifyListeners();
    });
  }

  setCurrentIndex(index) {
    _currentIndex = index;

    notifyListeners();
  }

  get currentIndex => _currentIndex;
}
